package com.brother.template.util;


import com.baomidou.mybatisplus.core.toolkit.Sequence;

import java.util.UUID;

/**
 * Id获取工具
 * 类似于 TableId 中的 IdType的ID_WORKER ，ID_WORKER_STR
 *
 * @author xjwtt
 * @date 2018/8/21
 */
public class GetId {

    public static String UUID() {
        return UUID.randomUUID().toString().replace("-", "").toLowerCase();
    }

    /**
     * 获得Long类型的Id
     *
     * @return
     */
    public static Long LID() {
        return SingleSequence.sequence.nextId();
    }

    /**
     * 获取String类型的ID 长度为 19
     *
     * @return
     */
    public static String SID() {
        return String.valueOf(SingleSequence.sequence.nextId());
    }

    private static class SingleSequence {
        private static Sequence sequence = new Sequence();
    }
}
